package com.kaigejava.juc.queue;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.concurrent.*;

public class ArrayBlockingQueueTest {

    public static void main(String[] args) {
        Collection<String> c1 = new ArrayList<String>();
        //声明队列大小为10的阻塞队列。默认非公平的
        Collection<String> c2 = new ArrayBlockingQueue<String>(10);
        //声明队列大小为10的阻塞队列,使用公平锁
        Collection<String> c3 = new ArrayBlockingQueue<String>(10,true);

        LinkedBlockingQueue lbQueue = new LinkedBlockingQueue();

        PriorityBlockingQueue<Integer> pBQueue = new PriorityBlockingQueue<Integer>(5);
        pBQueue.offer(1);
        pBQueue.offer(4);
        pBQueue.offer(3);
        pBQueue.offer(5);
        pBQueue.offer(2);
        pBQueue.forEach( obj ->{
            System.out.println(pBQueue.poll());
        });
        System.out.println("===========隔河相望=================");
        PriorityBlockingQueue<Integer> pBQueue2 = new PriorityBlockingQueue<Integer>(5,new MyComparator());
        pBQueue2.add(1);
        pBQueue2.add(5);
        pBQueue2.add(3);
        pBQueue2.add(4);
        pBQueue2.add(2);
        pBQueue2.forEach( obj ->{
            System.out.println(pBQueue2.poll());
        });

        DelayQueue dQueue = new DelayQueue();

        SynchronousQueue sQueue = new SynchronousQueue();

        LinkedTransferQueue ltQueue = new LinkedTransferQueue();
    }
}
